﻿using System;
using System.Collections.Generic;
using System.Text;
using Quartz;
using Model.Task;
using BLL.Business;
using AppToolKit.Core.Context.Spring;
using System.Data;
using IBLL;
using BLL.Action.Core.Base;
using IBLL.Business;

namespace BLL.Action.Job
{
    public class JobHand:JobBase
    {
       

        #region IJob 成员
        public const string Hotelid = "hotelid";

        public override void Execute(JobExecutionContext context)
        {
            base.Execute(context);

            string taskId = context.JobDetail.Name;

            List<string> Hotels = context.JobDetail.JobDataMap.Get(Hotelid) as List<string>;

            DataSet ds = TaskBusinessHolder.GetTask(taskId, Hotels);
            List<TaskDefine> tasks = new List<TaskDefine>();
            GetTaskdefine(ds, tasks);

            foreach (TaskDefine define in tasks)
            {
              IAction action= Factory.CreateAction(define.Action);
              action.Execute(define);
            }

        }
       
        
        #endregion

        public override  ITaskBusiness TaskBusinessHolder
        {
            get
            {
                TaskBusiness task = new TaskBusiness();
                ContextAwareHolder.AutowireObject(task);
                return task;
            }
             
        }
    }
}
